﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Fee.Mapping
{
    public class FrameworkContractMapping : IEntityTypeConfiguration<FrameworkContract>
    {
        public void Configure(EntityTypeBuilder<FrameworkContract> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();
            builder.Property(_ => _.Amount);
            builder.Property(_ => _.AmountWithoutTax);
            builder.Property(_ => _.Comment).HasMaxLength(256);
            builder.Property(_ => _.ContractDescription).HasMaxLength(256);

            builder.Property(_ => _.ContractType);
            ;

            builder.Property(_ => _.Name).HasMaxLength(128);
            builder.Property(_ => _.No)
                .HasMaxLength(128);
            builder.Property(_ => _.ReductionAmount);
            builder.Property(_ => _.SignTime);

            builder.Property(_ => _.Status);

            builder.Property(_ => _.ExpireTime);

            builder.HasOne(_ => _.Vendor);

            builder.HasIndex(_ => _.No);
            builder.Property(_ => _.NetType).HasMaxLength(32);
            builder.Property(_ => _.EffectYear).HasMaxLength(32);
            builder.ToTable("fee_FwContract");
        }
    }
}